<?xml version="1.0" encoding="utf-8" ?>

[#include "/WEB-INF/pages/common/taglibs.ftl"]

[#macro _script]
		<script type="text/javascript">
		
			var base = (function(){
				// 事件绑定
				function _addEventListeners() {
					$('a[act=edit]').click(function(){
						var id = $(this).parent().attr('tval');
						[@c.url var="editUrl" value='/manage/Category_edit.action' scope="page"]
							[#--[@c.param name="categoryId" value="${categoryId}"/]--]
						[/@c.url]
						
						window.location = "${editUrl}?categoryId=" + id;
					})
				
					$('a[act=delete]').click(function(){
						var id = $(this).parent().attr('tval');
						$( "#delete-confirm" ).dialog({
							resizable: false,
							height:160,
							width:260,
							modal: true,
							buttons: {
								"删除": function() {
									[@c.url var="backUrl" value='/manage/Category_list.action' scope="page"]
										[@c.param name="currentPage" value="${currentPage}"/]
									[/@c.url]
									window.location = "[@c.url value='/manage/Category_delete.action?cascade='/]" + $('#cascade').attr("checked") + "&id=" + id + "&backurl=${backUrl}";
									$( this ).dialog( "close" );
								},
								"取消": function() {
									$( this ).dialog( "close" );
								}
							}
						});
						$( "#delete:ui-dialog" ).dialog( "destroy" );
						return false;
					})
					// Create jqxExpander
	            	$('.jqxTabs').jqxTabs({ width:'500px', height: '260px', 
	            							selectionTracker: true, animationType: 'fade', 
	            							theme: base.config.theme });
	            	$('.channel_review').click(function(){
	            		var _$form = $(this).parents('form');
	            		var _action = _$form.attr('action');
	            		[@c.url var="review" value='/manage/Channel_review.action' scope="page"][/@c.url]
	            		var id = $(this).attr('ckey');
	            		//window.location = ${review};
	            		_$form.attr('action', '${review}').attr('target', '_bank');
	            		_$form.submit();
	            		_$form.attr('action', _action).removeAttr('target');
	            	})
				}
				return {
	                config: {
	                    theme: null
	                },
	                init: function () {
	                    _addEventListeners();
	                }
				}
			}());
		
			$(function(){
				base.config.url = "[@s.url value='/manage/Category_list.action?channelId=${channelId}'][/@s.url]";
				base.config.renderTo = "#categoryList";
				base.config.theme = getTheme();
	            //Initializing the form
            	base.init();		
			})
		</script>
[/#macro]
[#if piece==true]
	[@_script /]
	<!--设置提交行为-->
	[#assign act="save" /]
	[#include "/WEB-INF/pages/manage/_channelList.ftl"]
[#else]
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Insert title here</title>
		<meta name="menu" content="CategoryMenu"/>
		<meta name="heading" content="heading"/>
		
		<style type="text/css">
			.category {
				padding:0;
				margain:0;
			}
			.category_tree {
				width:200px;
				height:800px;
				float:left;
				margin-left:2px;
			}
			.category_list {
				height:800px;
				margin-left:212px;
			}
		</style>
		[@_script /]
	</head>
	<body id="body">
		<div class="channel">
			<div class="channel_list" id="channelList">
				<!--设置提交行为-->
				[#assign act="save" /]
				[#include "/WEB-INF/pages/manage/_channelList.ftl"]
			</div>
			<div style="clear: both;"></div>
		</div>
	</body>
	</html>
[/#if]